//
//  HotPlayCell.m
//  艾听歌
//
//  Created by dllo on 16/5/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HotPlayCell.h"


@interface HotPlayCell ()



@end

@implementation HotPlayCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.singerName = [[UILabel alloc] init];
        [self.contentView addSubview:self.singerName];
        
        self.aimage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.aimage];
        
        self.number = [[UILabel alloc] init];
        [self.contentView addSubview:self.number];
    
        self.desNmae = [[UILabel alloc] init];
        [self.contentView addSubview:self.desNmae];
        
        self.LoveButton = [[UIButton alloc] init];
        [self.contentView addSubview:self.LoveButton];
//        self.LoveButton.backgroundColor = [UIColor yellowColor];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.aimage.frame = CGRectMake(0, 0, WIDTH, 200);
    self.singerName.frame = CGRectMake(60, 10, WIDTH - 175, 30);
    self.desNmae.frame = CGRectMake(60, 45, WIDTH - 75, 30);
    self.desNmae.font = [UIFont systemFontOfSize:14];
    self.number.frame = CGRectMake(15, 25, WIDTH - 345, 30);
    self.LoveButton.frame = CGRectMake(320, 10, 30, 30);
    [self.LoveButton addTarget:self action:@selector(LoveButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.LoveButton setBackgroundImage:[UIImage imageNamed:@"list_menu_unfavorite-1"] forState:UIControlStateNormal];
//    [self.LoveButton setBackgroundImage:[UIImage imageNamed:@"❤️"] forState:UIControlStateSelected];
}

- (void)LoveButtonAction:(UIButton *)button
{
//    [[WTDataBaseHandle shareDataFMDBHandle] openMusicPlay];
    NSLog(@"+++======%@", self.model);
    NSMutableArray *array = [[WTDataBaseHandle shareDataFMDBHandle] selectMusicPlaywithCompare:NO];
    if ([array containsObject:self.model.name]) {
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"" preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
            
        }]];

    }else
    {
        [[WTDataBaseHandle shareDataFMDBHandle] inserterWithModel:self.model];
        
    }

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
